﻿using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Wfxin.RabbitMQ;
using Wfxin.Web.Api.MQ;

namespace Wfxin.Web.Api
{

    public interface IOrderConsumerClientFactory : IConsumerClientFactory { }

    internal sealed class RabbitMQOrderConsumerClientFactory : IOrderConsumerClientFactory
    {
        private readonly IOrderConnectionChannelPool _connectionChannelPool;
        private readonly RabbitMQOptions _rabbitMQOptions;

        public RabbitMQOrderConsumerClientFactory(IOptions<RabbitMQOptions> rabbitMQOptions, IOrderConnectionChannelPool channelPool)
        {
            _rabbitMQOptions = rabbitMQOptions.Value;
            _connectionChannelPool = channelPool;
        }

        public IConsumerClient Create(string groupId)
        {
            return new RabbitMQOrderConsumerClient(groupId, _connectionChannelPool, _rabbitMQOptions);
        }
    }
}
